package com.haoshuang.zhouzhoubang.ui.page.shop

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.ShopSort
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class ShoppingViewModel : BaseViewModel() {
    val getData2 = StatefulMutableLiveData<ArrayList<ShopSort>>()
    fun getData2(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ArrayList<ShopSort>>("api/Goods/getCateList", *params,
                onStart = {
                    getData2.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData2.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData2.value = StateData.Success(it)
                })
        }
    }

}